package com.quanyan.assets.mapper;

import com.quanyan.assets.entity.TbCouponInfo;
import com.quanyan.assets.entity.vo.CouponItem;
import com.quanyan.assets.request.ReqCoupon;
import com.quanyan.assets.response.RespCoupon;
import com.quanyan.assets.response.RespSimpleCoupon;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 *
 * Created by wmb on 2016/10/9.
 */
public interface CouponMapper {
    //获取已领取的优惠券
    List<RespCoupon> getReceiveCouponList(ReqCoupon reqCoupon);
    //获取失效列表
    List<RespCoupon> getExpiredCouponList(ReqCoupon reqCoupon);
    //获取订单使用的优惠券列表
    List<RespCoupon> getOrderCouponList(@Param("reqCoupon") ReqCoupon reqCoupon,@Param("stateTime") Date stateTime, @Param("endTime") Date endTime);

    int freezeByCode(@Param("reqCoupon") ReqCoupon reqCoupon, @Param("stateTime") Date stateTime, @Param("endTime") Date endTime);

    RespCoupon selectInfoByCode(String couponCode);

    int unfreezeComplate(ReqCoupon reqCoupon);

    int associateUsers(ReqCoupon reqCoupon);

    List<RespCoupon> usedCouponList(@Param("reqCoupon") ReqCoupon reqCoupon, @Param("stateTime") Date stateTime, @Param("endTime") Date endTime);

    //获取拥有失效卡券的用户uid
    List<TbCouponInfo> getInvalidCouponInfoCountInfo(@Param("time") Date time);

    //更改过期的卡券状态为无效状态
    int hideInvalidCoupon(@Param("uid") Integer uid, @Param("time") Date time);

    //领取一张优惠券
    int grantCouponTopOne(@Param("couponId") String couponId, @Param("uid") Integer uid, @Param("mobile") String mobile, @Param("validBeginDate") String validBeginDate, @Param("validEndDate") String validEndDate);

    //获取优惠券模板信息
    RespSimpleCoupon getCoupon(@Param("couponId") String couponId);

    // 获取活动优惠券列表
    List<CouponItem> getActivityCouponList(@Param("activityType") byte activityType);

    /**
     * 更新领取数量
     * @param couponInfoId
     */
    void updateReciveNum(@Param("couponInfoId") int couponInfoId);

    void refundSubmit(String couponCode);

    void refundSuccess(String couponCode);

    void refundFail(String couponCode);
}
